-
-
Notifications
You must be signed in to change notification settings - Fork 363
perf(Table): use ReferenceEqualityComparer instance #6238
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Reviewer's GuideThis pull request enhances dictionary lookup performance by configuring the two ConcurrentDictionary caches to use reference equality when comparing ITableColumn keys. Sequence Diagram: Cache Lookup Using Reference EqualitysequenceDiagram
participant Caller as "IsLastColumn / IsFirstColumn"
participant Cache as "ConcurrentDictionary (e.g., LastFixedColumnCache)"
participant REC as "ReferenceEqualityComparer.Instance"
participant KeyToLookup as "ITableColumn (key)"
Caller->>Cache: GetOrAdd(KeyToLookup, valueFactory)
activate Cache
Cache->>REC: Equals(KeyToLookup, existingCacheKey)
activate REC
REC-->>Cache: bool (reference equality result)
deactivate REC
alt Key found by reference
Cache-->>Caller: CachedValue
else Key not found or different reference
Cache-->>Caller: NewValue (after computing and storing)
end
deactivate Cache
Class Diagram: Table Cache Configuration UpdateclassDiagram
class Table {
-LastFixedColumnCache: ConcurrentDictionary~ITableColumn, bool~
-FirstFixedColumnCache: ConcurrentDictionary~ITableColumn, bool~
+IsLastColumn(col: ITableColumn) : bool
+IsFirstColumn(col: ITableColumn) : bool
}
class ConcurrentDictionary~TKey, TValue~ {
+ConcurrentDictionary(comparer: IEqualityComparer~TKey~)
}
class ReferenceEqualityComparer {
<<static>> +Instance : IEqualityComparer
}
class ITableColumn {
<<interface>>
}
Table o-- "2" ConcurrentDictionary : has caches
Table ..> ReferenceEqualityComparer : uses Instance for initializing caches
ConcurrentDictionary ..> ITableColumn : TKey for caches
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
Thanks for your PR, @kimdiego2098. Someone from the team will get assigned to your PR shortly and we'll get it reviewed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @kimdiego2098 - I've reviewed your changes and they look great!
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location> `src/BootstrapBlazor/Components/Table/Table.razor.Sort.cs:247` </location>
<code_context>
private bool IsLastExtendButtonColumn() => IsExtendButtonsInRowHeader && !GetVisibleColumns().Any(i => i.Fixed);
- private ConcurrentDictionary<ITableColumn, bool> FirstFixedColumnCache { get; } = new();
+ private ConcurrentDictionary<ITableColumn, bool> FirstFixedColumnCache { get; } = new(ReferenceEqualityComparer.Instance);
private bool IsFirstColumn(ITableColumn col) => FirstFixedColumnCache.GetOrAdd(col, col =>
</code_context>
<issue_to_address>
Double-check use of reference equality for columns
ReferenceEqualityComparer requires that the same column object instance is used consistently; otherwise, cache misses may occur. Confirm this behavior is intentional.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #6238 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 704 704
Lines 31121 31121
Branches 4400 4400
=========================================
Hits 31121 31121
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Co-Authored-By: Diego2098 <[email protected]>

Issues
close #6239
字典操作很频繁,增加一点点性能
Summary by Sourcery
Use reference equality comparer for table column caches to reduce dictionary overhead and improve performance
Enhancements: